import 'dart:convert' show json;

class DateEvents {
  int? createTime;
  List<Event?>? events;

  DateEvents.fromParams({this.createTime, this.events});

  factory DateEvents(Object jsonStr) => jsonStr is String
      ? DateEvents.fromJson(json.decode(jsonStr))
      : DateEvents.fromJson(jsonStr);

  static DateEvents? parse(jsonStr) =>
      ['null', '', null].contains(jsonStr) ? null : DateEvents(jsonStr);

  DateEvents.fromJson(jsonRes) {
    createTime = jsonRes['create_time'];
    events = jsonRes['events'] == null ? null : [];

    for (var eventsItem in events == null ? [] : jsonRes['events']) {
      events!.add(eventsItem == null ? null : Event.fromJson(eventsItem));
    }
  }

  @override
  String toString() {
    return '{"create_time": $createTime, "events": $events}';
  }

  String toJson() => this.toString();
}

class Event {
  int? createTime;
  int? duration;
  int? type;

  Event.fromParams({this.createTime, this.duration, this.type});

  Event.fromJson(jsonRes) {
    createTime = jsonRes['create_time'];
    duration = jsonRes['duration'];
    type = jsonRes['type'];
  }

  @override
  String toString() {
    return '{"create_time": $createTime, "duration": $duration, "type": $type}';
  }

  String toJson() => this.toString();
}
